Skip to content

Add tgsen! (ordschur!) and tgevc! (eigenvectors from Schur form) - #54

Open
pablosanjose wants to merge 1 commit into
DynareJulia:mainfrom
pablosanjose:complex-tgsen-tgevc
Open

pablosanjose wants to merge 1 commit into
DynareJulia:mainfrom
pablosanjose:complex-tgsen-tgevc

Conversation

@pablosanjose

Copy link
Copy Markdown

This is the second functionality we were missing in Quantica.jl, following up on #53. After the generalized Schur decomposition of a complex pencil, we reorder it (ordschur!) and then extract eigenvectors directly from the Schur form. This PR adds workspaces for both steps, for complex matrices: GeneralizedOrdSchurWs for LAPACK.tgsen!, and GeneralizedEigenvectorsWs for tgevc!. It is independent of #53, and the two merge cleanly in either order.

The main thing to focus on is tgevc!. Unlike tgsen!, LinearAlgebra.LAPACK has no tgevc!, so this defines a new function FastLapackInterface.tgevc!, which I did not export. Happy to change the name, export it, or split it into a separate PR if you prefer.

I've done my best to follow the style and conventions in the rest of the package. If you feel you'd like tweaks just let me know.

I've again used Claude Code to help me, but I've thoroughly reviewed any change it proposed.

Changes

  • GeneralizedOrdSchurWs + LAPACK.tgsen!(ws, select, S, T, Q, Z) (ztgsen/ctgsen). Same arguments and return value as LinearAlgebra.LAPACK.tgsen!(select, S, T, Q, Z), just with the workspace first. It's the non-allocating version of ordschur! for a GeneralizedSchur. Condition numbers are not computed (ijob = 0), as in LinearAlgebra.
  • GeneralizedEigenvectorsWs + FastLapackInterface.tgevc!(ws, side, howmny, select, S, P, VL, VR) (ztgevc/ctgevc). Returns (VL, VR, m). VL/VR are not resized, so they can be views.
  • Both workspaces are exported, and get a Workspace(lapack_function, A) constructor, a decompose! method, docstrings with doctests, and entries in docs/src.
  • Both allocate nothing after warm-up.

Tests

test/schur_test.jl gets a "Complex, square" testset for each workspace (ComplexF64 and ComplexF32). tgsen! is compared against LAPACK.tgsen!. For tgevc! we check eigenvector residuals against the original pencil, howmny = 'S' into a view, and the Workspace/factorize! path, plus resizing / WorkspaceSizeError for both. The full suite passes locally on Julia 1.10 and 1.13.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant